import time
def bubble_sort(nums):
# Устанавливаем swapped в True, чтобы цикл запустился хотя
    swapped = True
    a = time.time()
    while swapped:
        swapped = False
        for i in range(len(nums) - 1):
           if nums[i] > nums[i + 1]:
             nums[i], nums[i + 1] = nums[i + 1], nums[i]
             swapped = True
             b=time.time()
             return round (((b-a)*1000))
def read2list(filename):
  file = open(filename, 'r')
  data = file.readlines()
  return data

m1 = read2list("m1_sorted.txt")
m2 = read2list("m2_reverse.txt")
m3 = read2list("m3_shuffle.txt")

print('m1_sorted',bubblu_sort(m1),'millisecond')
print('m2_sorted',bubblu_sort(m2),'millisecond')
print('m3_sorted',bubblu_sort(m3),'millisecond')